package com.zygh.lz.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zygh.lz.dao.TaskScheduleMapper;
import com.zygh.lz.entity.duty.TaskSchedule;
import com.zygh.lz.service.TaskScheduleService;
import com.zygh.lz.stapprove.ResultUtil;
import com.zygh.lz.vo.ResultBean;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author lee
 */
@Service
public class TaskScheduleServiceImpl implements TaskScheduleService {
    @Resource
    private TaskScheduleMapper taskScheduleMapper;
    @Override
    public ResultBean find(TaskSchedule taskSchedule) {
        PageHelper.startPage(taskSchedule.getPageNum(),taskSchedule.getPageSize());
        List<TaskSchedule> taskSchedules = taskScheduleMapper.selectList(Wrappers.emptyWrapper());

        PageInfo<TaskSchedule> data = new PageInfo<>(taskSchedules);
        return ResultUtil.setOK("查询成功",data);
    }

    @Override
    public ResultBean add(TaskSchedule taskSchedule) {
        int insert = taskScheduleMapper.insert(taskSchedule);

        return ResultUtil.execOp(insert,"插入");
    }

    @Override
    public ResultBean update(TaskSchedule taskSchedule) {
        int update = taskScheduleMapper.updateById(taskSchedule);
        return ResultUtil.execOp(update,"修改");
    }

    @Override
    public ResultBean delete(TaskSchedule taskSchedule) {
        int delete = taskScheduleMapper.deleteById(taskSchedule);
        return ResultUtil.execOp(delete,"修改");
    }
}
